package com.trace.app.controller;


import com.trace.app.entity.ResponseResult;
import com.trace.app.entity.Role;
import com.trace.app.service.RoleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 角色表(Role)表控制层
 *
 * @author lionkliu
 * @since 2024-03-31 09:54:43
 */
@RestController
@RequestMapping("role")
public class RoleController {

    @Resource
    private RoleService roleService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return roleService.selectPage(pageNum, pageSize);
    }

    @GetMapping("/getLabelValue")
    public ResponseResult getLabelValue() {
        return roleService.getLabelValue();
    }

    @GetMapping("{id}")
    public ResponseResult selectOne(@PathVariable Integer id) {
        return roleService.selectOne(id);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody Role role) {
        return roleService.insertOne(role);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Role role) {
        return roleService.updateOne(role);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return roleService.deleteById(id);
    }

}
